﻿using System;
using System.Collections;
using ParticlePlayground;

namespace UnityEngine
{
	// Token: 0x020000FB RID: 251
	public class PlaygroundRecordingMultiExample : MonoBehaviour
	{
		// Token: 0x06000582 RID: 1410 RVA: 0x00022154 File Offset: 0x00020354
		public virtual IEnumerator Start()
		{
			this.guiArea = new Rect(10f, 10f, (float)Screen.width * 0.5f, 130f);
			if (this.recordFromStart)
			{
				for (int i = 0; i < this.playgroundMultiRecorder.playgroundRecorders.Length; i++)
				{
					while (!this.playgroundMultiRecorder.playgroundRecorders[i].playgroundSystem.IsReady())
					{
						yield return null;
					}
				}
				this.playgroundMultiRecorder.StartRecording(this.keyframeInterval);
			}
			yield break;
		}

		// Token: 0x06000583 RID: 1411 RVA: 0x00022170 File Offset: 0x00020370
		public virtual void Update()
		{
			if (this.hoveringScrubSlider && Input.GetMouseButton(0))
			{
				this.isScrubbing = true;
			}
			else if (Input.GetMouseButtonUp(0))
			{
				this.isScrubbing = false;
			}
			if (this.isScrubbing)
			{
				this.playgroundMultiRecorder.Scrub(this.playbackSliderValue);
			}
		}

		// Token: 0x06000584 RID: 1412 RVA: 0x000221D0 File Offset: 0x000203D0
		public virtual void OnGUI()
		{
			GUILayout.BeginArea(this.guiArea, "Playground Multi Recorder");
			GUILayout.Space(18f);
			GUILayout.BeginHorizontal(new GUILayoutOption[0]);
			if (GUILayout.Button(this.playgroundMultiRecorder.playgroundRecorders[0].IsRecording() ? "Stop Recording" : "Record", new GUILayoutOption[0]))
			{
				if (!this.playgroundMultiRecorder.playgroundRecorders[0].IsRecording())
				{
					this.playgroundMultiRecorder.StartRecording(this.keyframeInterval);
				}
				else
				{
					this.playgroundMultiRecorder.StopRecording();
				}
			}
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(new GUILayoutOption[0]);
			GUILayout.Label("Time (" + ((float)this.playgroundMultiRecorder.playgroundRecorders[0].FrameCount() * this.keyframeInterval * this.playbackSliderValue).ToString("F1") + ")", new GUILayoutOption[]
			{
				GUILayout.MaxWidth(40f)
			});
			this.playbackSliderValue = GUILayout.HorizontalSlider(this.playbackSliderValue, 0f, 1f, new GUILayoutOption[0]);
			if (this.playgroundMultiRecorder.playgroundRecorders[0].IsRecording())
			{
				this.playbackSliderValue = 1f;
			}
			this.hoveringScrubSlider = (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition));
			GUILayout.EndHorizontal();
			GUILayout.EndArea();
		}

		// Token: 0x0400059C RID: 1436
		public ParticlePlayground.PlaygroundMultiRecorder playgroundMultiRecorder;

		// Token: 0x0400059D RID: 1437
		public float keyframeInterval = 0.1f;

		// Token: 0x0400059E RID: 1438
		public bool recordFromStart = true;

		// Token: 0x0400059F RID: 1439
		public Rect guiArea;

		// Token: 0x040005A0 RID: 1440
		public bool hoveringScrubSlider;

		// Token: 0x040005A1 RID: 1441
		public bool isScrubbing;

		// Token: 0x040005A2 RID: 1442
		public float playbackSliderValue;
	}
}
